package com.qianfeng.teachdemo.ui;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.TypedValue;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;


import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.lidroid.xutils.bitmap.factory.BitmapFactory;
import com.qianfeng.teachdemo.R;
import com.qianfeng.teachdemo.adapter.LeftAdapter;
import com.qianfeng.teachdemo.bean.MenuIconMenu;
import com.qianfeng.teachdemo.fragment.LeftFragment;
import com.qianfeng.teachdemo.fragment.ValidationFragment;
import com.qianfeng.teachdemo.ui.eventBus.EventBusActivity;
import com.qianfeng.teachdemo.ui.webservice.WebServiceActivity;
import com.qianfeng.teachdemo.utils.AppManager;

import java.util.ArrayList;


/**
 * @version v1.0
 * @类描述：
 * @项目名称：VolleyaDemo
 * @包 名： com.qianfeng.volleyademo.ui
 * @类名称：BaseActivity
 * @创建人：张唯
 * @创建时间：14-9-30
 * @修改人：
 * @修改时间：
 * @修改备注：
 */
public class BaseActivity extends ActionBarActivity implements  View.OnClickListener,LeftFragment.OnFragmentInteractionListener {
    public Activity activity;
    public SlidingMenu menu;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        activity = this;
        AppManager.getAppManager().addActivity(this);
    }

    /**
     *
     *
     */
    protected void initSlidingMenu() {
        menu = new SlidingMenu(this);// 实例化
        menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
        menu.setMode(SlidingMenu.LEFT_RIGHT);
        menu.setShadowWidthRes(R.dimen.shadow_width);// 设置阴影的宽度
        menu.setBehindOffset(getWindowManager().getDefaultDisplay().getWidth() / 3);// 设置菜单滑出是主界面的宽度
        menu.setFadeEnabled(true);// 设置渐变效果
        menu.setFadeDegree(0.35f);// 设置渐变值
        // 设置左边的menu布局
        menu.setMenu(R.layout.menu_left_container);
        menu.setSecondaryMenu(R.layout.menu_right_layout);
        menu.attachToActivity(activity, SlidingMenu.SLIDING_WINDOW);
        LeftFragment fragment = new LeftFragment();
        fragment.setmListener(this);
        getSupportFragmentManager().beginTransaction().add(R.id.menu_left_container,fragment).commit();
        menu.showContent();

    }

//    public void upload(){
//        UpdateManager manager = new UpdateManager(this);
//        UpdateOptions options = new UpdateOptions.Builder(this)
//                .checkUrl("https://raw.github.com/snowdream/android-autoupdate/master/docs/test/updateinfo.xml")
//                .updateFormat(UpdateFormat.XML)
//                .updatePeriod(new UpdatePeriod(UpdatePeriod.EACH_TIME))
//                .checkPackageName(true)
//                .build();
//        manager.check(this, options);
//    }




    @Override
    public void onClick(View v) {
//        switch (v.getId()) {
//            case R.id.menu_right_icon:
//                break;
//            case R.id.menu_right_loginBtn:
//                startActivity(new Intent(this, LoginActivity.class));
//                break;
//        }
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        AppManager.getAppManager().finishActivity(this);
    }

    @Override
    public void onFragmentInteraction() {
        menu.showSecondaryMenu();
    }
}
